
package ProOF.apl.problems.real.operators;

import ProOF.apl.problems.real.RealCodification;
import ProOF.apl.problems.real.RealProblem;
import ProOF.gen.operator.oCrossover;

/**
 *
 * @author Hossomi
 */
public class RealCrossOX extends oCrossover<RealProblem, RealCodification> {

    @Override
    public String name() {
        return "Uniform";
    }

    @Override
    public RealCodification crossover(RealProblem prob, RealCodification ind1, RealCodification ind2) throws Exception {
        RealCodification child = ind1.New(prob);
        double prod;
        for (int i = 0; i < prob.func.dimension(); i++) {
            if (prob.rmd.nextDouble() < 0.5)
                child.x[i] = ind1.x[i];
            else
                child.x[i] = ind2.x[i];
        }
        
        return child;
    }

}
